@isTest
private class WeekPlanTest {
    static testMethod void myUnitTest() {
        Account acc = TestUtils.createAccount();
        acc.Name = 'TestAcc';
        acc.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('TerminalCustomer','Account');
        acc.SpecialDepart__c = '内科_呼吸内科; 内科_神经内科';
        acc.CustomerAttribute__c = '公立医疗机构';
        insert acc;
        
        Contact con=new Contact();
        con.AccountId=acc.Id;
        con.LastName='TestCon';
        insert con;
        

        Opportunity opp = new Opportunity();
        opp.Name = 'TestOpp';
        opp.AccountId = acc.Id;
        opp.StageName = '意向';
        opp.Department__c = '检验科';
        opp.CloseDate = Date.newInstance(2017, 3, 13);
        opp.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('CustomerOpportunity','Opportunity');
        insert opp;
        
        Weekly_Plan__c wp=new Weekly_Plan__c();
        wp.Start_Date__c=Date.today();
        wp.End_Date__c=Date.today();
        insert wp;
        
        Event eve=new Event();
        eve.WhatId=acc.Id;
        eve.Subject='sub';
        eve.StartDateTime=Datetime.now();
        eve.EndDateTime=Datetime.now();
        eve.Travel_Fee__c=1;
        eve.Busness_Fee__c=1;
        eve.Week_Plan__c=wp.Id;
        insert eve;
        
        Campaign cam=new Campaign();
        cam.Name='TestCampaign';
        cam.ActivitySite__c='beijing';
        cam.AnnualBudgetTypes__c='年度预算内活动';
        insert cam;
        
        ApexPages.StandardController lce = new ApexPages.StandardController(wp);
        //销售部创建周计划
        WeekPlanCreatedExtension controller = new WeekPlanCreatedExtension(lce);
        controller.strjson='[{"cam":"","opp":"' + opp.Id + '","con":"' + con.Id + '","sub":"a","acc":"' + acc.Id + '","type":"拜访","address":"a","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controller.save();
        controller.strjson='[{"cam":"","opp":"","con":"","sub":"dd","acc":"' + acc.Id + '","type":"拜访","address":"dd","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controller.save();
        controller.strjson='[{"cam":"' + cam.Id + '","opp":"","con":"","sub":"dd","acc":"' + acc.Id + '","type":"拜访","address":"dd","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controller.save();
        controller.cancle();
        //销售部编辑周计划
        WeekPlanEdit controllerEdit = new WeekPlanEdit(lce);
        controllerEdit.strjson='[{"enentId":"' + eve.Id + '","cam":"","opp":"' + opp.Id + '","con":"' + con.Id + '","sub":"a","acc":"' + acc.Id + '","type":"拜访","address":"a","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controllerEdit.save();
        controllerEdit.strjson='[{"enentId":"' + eve.Id + '","cam":"","opp":"","con":"","sub":"dd","acc":"' + acc.Id + '","type":"拜访","address":"dd","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controllerEdit.save();
        controllerEdit.strjson='[{"enentId":"' + eve.Id + '","cam":"' + cam.Id + '","opp":"","con":"","sub":"dd","acc":"' + acc.Id + '","type":"拜访","address":"dd","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controllerEdit.save();
        controllerEdit.cancle();
        
        //市场部创建周计划
        WeekPlanCreatedCampaignExtension controllerCam= new WeekPlanCreatedCampaignExtension(lce);
        controllerCam.strjson='[{"cam":"","opp":"' + opp.Id + '","con":"' + con.Id + '","sub":"a","acc":"' + acc.Id + '","type":"拜访","address":"a","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controllerCam.save();
        controllerCam.strjson='[{"cam":"","opp":"","con":"","sub":"dd","acc":"' + acc.Id + '","type":"拜访","address":"dd","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controllerCam.save();
        controllerCam.strjson='[{"cam":"' + cam.Id + '","opp":"","con":"","sub":"dd","acc":"' + acc.Id + '","type":"拜访","address":"dd","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controllerCam.save();
        controllerCam.cancle();
        
        //市场部编辑周计划
        WeekPlanEditCampaign controllerCamEdit = new WeekPlanEditCampaign(lce);
        controllerCamEdit.strjson='[{"enentId":"' + eve.Id + '","cam":"","opp":"' + opp.Id + '","con":"' + con.Id + '","sub":"a","acc":"' + acc.Id + '","type":"拜访","address":"a","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controllerCamEdit.save();
        controllerCamEdit.strjson='[{"enentId":"' + eve.Id + '","cam":"","opp":"","con":"","sub":"dd","acc":"' + acc.Id + '","type":"拜访","address":"dd","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controllerCamEdit.save();
        controllerCamEdit.strjson='[{"enentId":"' + eve.Id + '","cam":"' + cam.Id + '","opp":"","con":"","sub":"dd","acc":"' + acc.Id + '","type":"拜访","address":"dd","startvisitdate":"2016-06-04 09:00","endvisitdate":"2016-06-04 10:00"}]';
        controllerCamEdit.save();
        controllerCamEdit.cancle();
    }
}